﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Spritehand.FarseerHelper
{
    public class Utilities
    {
        public static bool IsDesignMode
        {
            get
            {
                return Windows.ApplicationModel.DesignMode.DesignModeEnabled;
            }

        }

        public static bool IsDebugMode
        {
            get
            {
                return (System.Diagnostics.Debugger.IsAttached);
            }
        }

        public static string GetCurrentVersion()
        {
            return Windows.ApplicationModel.Package.Current.Id.Version.Major.ToString() + "." +
                 Windows.ApplicationModel.Package.Current.Id.Version.Minor.ToString() + "." +
                 Windows.ApplicationModel.Package.Current.Id.Version.Revision.ToString();
        }

        public static int VersionToNumeric(string version)
        {
            int retval = 0;

            // if no version then default to first release
            if (version == null)
                version = "1.0.1";

            string[] versionSplits = version.Split('.');

            for (int i = 0; i < versionSplits.Length; i++)
            {
                retval += Convert.ToInt32(Math.Pow(1000, (versionSplits.Length - i - 1)) * Convert.ToInt32(versionSplits[i])); 
            }

            return retval;
        }


    }
}
